package ex2.ccf.windows;

import java.util.Scanner;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/10 20:42
 * @DESCRIBE
 */
public class Window {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        //二维数组放x y
        int[][] x = new int [n][3];
        int[][] y = new int [n][2];
        for (int i = 0 ;i < n; i++){
            x[i][0] = sc.nextInt();
            y[i][0] = sc.nextInt();
            x[i][1] = sc.nextInt();
            y[i][1] = sc.nextInt();
            x[i][2] = i+1;
        }
        for (int i = 0; i< m; i++){
            int xi = sc.nextInt();
            int yi = sc.nextInt();

            //鼠标点击没有窗口，输出ignore
            boolean flag = true;

            //输入窗口从最底层到最顶层，那么鼠标点击窗口应从最顶层到最低层
            for(int j = n-1 ; j >= 0;j--){
                if (xi >= x[j][0] && xi <= x[j][1] && yi >= y[j][0] && yi <= y[j][1]){
                    flag = false;
                    System.out.println(x[j][2]);

                    int[] tmp_x = x[j];
                    int[] tmp_y = y[j];
                    for (int k = j+1; k < n; k++){
                        x[k-1] = x[k];
                        y[k-1] = y[k];
                    }
                    x[n-1] = tmp_x;
                    y[n-1] = tmp_y;
                    break;
                }
            }if (flag){
                System.out.println("ignored");
            }
        }
    }
}
